function CorPostWrapper(width, height, ip = '127.0.0.1', port = '5000') {
    this.x1 = 0;
    this.x2 = 0;
    this.y1 = 0;
    this.y2 = 0;
    this.ip = ip;
    this.port = port;
    this.width = width;
    this.height = height;
    this.location = '/';
    this.selected_images_files = {};
    this.trace_type = '';
    this.objURL = '';
    console.log('PostWrapper inited');
}

CorPostWrapper.prototype = {

    do_post: function (location = '/coordinates') {
        this.location = location;

        console.log('posting');
        data_tmp = {
            'x1': this.x1,
            'x2': this.x2,
            'y1': this.y1,
            'y2': this.y2,
            'width': this.width,
            'height': this.height
        };
        data_array = [];
        for (i = 0; i < this.selected_images_files.length; i++) {
            var node = {"file": this.selected_images_files[i].name};
            data_array.push(node);
        }
        data_tmp['files'] = data_array;
        data_tmp['trace_type'] = this.trace_type;
        data_tmp['objURL'] = this.objURL;
        console.log(data_tmp);
        $.ajax({
            type: "POST",
            url: this.location,
            dataType: "json",
            data: data_tmp,
            success: function (data) {
                console.log('post success');
                console.log(JSON.stringify(data));
            },
            error: function (e) {
                console.log("post error:");
                console.log(e)
            }
        });
    },
    set_xy: function (x1, x2, y1, y2) {
        this.x1 = x1 / this.width;
        this.x2 = x2 / this.width;
        this.y1 = y1 / this.height;
        this.y2 = y2 / this.height;
    }
};